Minimum Moves for adjacent stars
Given a string s consisting of ‘.’ and ‘*’, In one move you can shift ‘*’, one index left or one index right if there is a ‘.’ present there, the task is to make an arrangement such that all the * are adjacent to each other i.e. there is no ‘.’ between any two ‘*’ Print the minimum number of moves required to do so....
read more
Make elements of Array equal by repeatedly dividing elements by 2 or 3
Given an integer array A consisting of N integers. In one move, we can choose any index i ( 0 ≤ i ≤ N-1) and divide it either by 2 or 3(the number A[i] should be divisible by 2 or 3, respectively), the task is to find the minimum number of total moves required such that all array elements are equal. If it is not possible to make all elements equal, print -1....
read more
Find out the person who got the ticket last.
N people from 1 to N are standing in the queue at a movie ticket counter. It is a weird counter, as it distributes tickets to the first K people and then the last K people and again the first K people, and so on, once a person gets a ticket moves out of the queue. The task is to find the last person to get the ticket....
read more
Sudo Placement[1.3] | Final Destination
Given an array of integers and a number K with initial and final values. Your task is to find the minimum number of steps required to get final value starting from the initial value using the array elements. You can only do add (add operation % 1000) on values to get the final value. At every step, you are allowed to add any of the array elements with modulus operation....
read more
Minimum elements to be removed to make pairwise Bitwise XOR 0 or 1
Given an array X[] of length N. Then your task is to output the minimum number of elements needed to remove so that the Bitwise XOR of any pair is either 0 or 1....
read more
Equalize all Array elements by dividing with another Array element
Given an array arr[] of N positive integers (> 0). The task is to check if it is possible to make all array elements equal by performing the given operation. Print “Yes” if possible, else print “No“. The operation that can be performed is...
read more
Remove minimum characters from string to split it into three substrings under given constraints
Given a string str of lowercase alphabets, the task is to remove minimum characters from the given string so that string can be break into 3 substrings str1, str2, and str3 such that each substring can be empty or can contains only characters ‘a’, ‘b’, and ‘c’ respectively.Example:...
read more
Count distinct points visited on the number line
Given a person who is at position current_pos and a binary string path which is the moves the person took, if path[i] = ‘0’ then the person moved one step left, and if path[i] = ‘1’ then the person moved one step to the right. The task is to find the count of distinct positions the person visited....
read more
Minimum increment/decrement operations required on Array to satisfy given conditions
Given an array arr[] of size N, the task is to find the minimum number of increment or decrement operations required at any index i such that for each i (1 ? i < N) if the sum of elements at index from 1 to i is positive then the sum of elements from 1 to i + 1 must be negative or vice versa....
read more
CSES Solutions – Room Allocation
There is a large hotel, and N customers will arrive soon. Each customer wants to have a single room....
read more
Min steps to empty an Array by removing a pair each time with sum at most K
Given an array arr[] and a target value K. The task is to find the minimum number of steps required to take all elements from the array. In each step, at most two elements can be selected from array such that their sum must not exceed target value K. Note: All the elements of the array are less than or equals to K....
read more
Counting even integers in modified Sequence
Given an integer array A of size N, and Q queries. In each query, you are given an integer X. Create a new sequence X^A[i], say sequence B. For each query find the number of even integers in the modified sequence for a given value of X....
read more